home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swags_z.zip / SCROLL.SWG / 0004_SCROLL4.PAS.pas < prev    next >
Pascal/Delphi Source File  |  1993-05-28  |  1KB  |  64 lines

  1. {> I need to be able to scroll the Text display in my File viewer,
  2. > both left and right, to allowing reading of lines that extend past
  3. > column 80.
  4.  
  5. UnFortunately there's no way to scroll horizontally by BIOS or by another
  6. service Function. You have to implement it on your own. Here are two Procedures
  7. that I use in my Programs (in Case they must scroll left or right ;-)):
  8. }
  9.  
  10. {$ifNDEF VER70}
  11. Const
  12.   Seg0040   = $0040;
  13.   SegB000   = $B000;
  14.   SegB800   = $B800;
  15. {$endif}
  16.  
  17. Type
  18.   PageType  = Array [1..50,1..80] of Word;
  19.  
  20. Var
  21.   Screen    : ^PageType;
  22.   VideoMode : ^Byte;
  23.  
  24. Procedure ScrollRight(X1,Y1,X2,Y2,Attr : Byte);
  25. Var
  26.   Y      : Byte;
  27.   Attrib : Word;
  28. begin
  29.   Attrib := Word(Attr SHL 8);
  30.   Y      := Y1-1;
  31.   Repeat
  32.     Inc(Y);
  33.     Move(Screen^[Y,X1],Screen^[Y,X1+1],(X2-X1)*2);
  34.     Screen^[Y,X1] := Attrib+32;
  35.   Until Y=Y2;
  36. end;
  37.  
  38. Procedure ScrollLeft(X1,Y1,X2,Y2,Attr : Byte);
  39. Var
  40.   Y      : Byte;
  41.   Attrib : Word;
  42. begin
  43.   Attrib := Word(Attr SHL 8);
  44.   Y      := Y1-1;
  45.   Repeat
  46.     Inc(Y);
  47.     Move(Screen^[Y,X1+1],Screen^[Y,X1],(X2-X1)*2);
  48.     Screen^[Y,X2] := Attrib+32;
  49.   Until Y=Y2;
  50. end;
  51.  
  52. begin
  53.   VideoMode := Ptr(Seg0040,$0049);
  54.   if VideoMode^=7 then
  55.     Screen := Ptr(SegB000,$0000)
  56.   else
  57.     Screen := Ptr(SegB800,$0000);
  58. end.
  59.  
  60. {
  61. X1, Y1, X2 and Y2 are the coordinates of the Windows to be scrolled. Attr is
  62. the color of the vertical line that occurs after scrolling. ;-)
  63. }
  64.